package com.project.zsxd.server.common.util;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;

public class LocalDateUtil {


    public static LocalDate parse(String date) {
        return LocalDate.parse(date);
    }

    public static String format(LocalDate date) {
        return date.format(DateTimeFormatter.ISO_LOCAL_DATE);
    }

    /**
     * 获得当月第一天
     * @param date 日期
     * @return 当月第一天
     */
    public static LocalDate getFirstOfMonth(LocalDate date) {
        return date.with(TemporalAdjusters.firstDayOfMonth());
    }

    /**
     * 获得当月最后一天
     * @param date 日期
     * @return 当月最后一天
     */
    public static LocalDate getLastOfMonth(LocalDate date) {
        return date.with(TemporalAdjusters.lastDayOfMonth());
    }

}
